shouldThrowWithMessage

Verify that an exception is thrown with the right message

void
shouldThrowWithMessage
(
T : Throwable = Exception
E
)
(
lazy E expr
,
string msg
,
string file = __FILE__
,
size_t line = __LINE__
)

Examples

1 void funcThrows(string msg) {
2     throw new Exception(msg);
3 }
4 
5 funcThrows("foo bar").shouldThrowWithMessage!Exception("foo bar");
6 funcThrows("foo bar").shouldThrowWithMessage("foo bar");

Meta